<?php
if( !defined('IN_INDEX') )
{
	printError("ACCESS DENIED", "This page is hidden.");
	exit;
}
if(!checkSession())
{
			function redirect($url)
			{
			?>
				<script type="text/javascript">
					{
					window.location = "<?=$url?>";
					}
				</script>
			<?php 
			}
			redirect("index.php?action=login");
	exit;
}
else
{
	if(isset($_REQUEST['id']))
	{
		$USER_PROFILE = new User('id', $_REQUEST['id']);
		$page_url = "index.php?action=profile&sub=info&id" . $_REQUEST['id'];
	}
	else
	{
		$USER_PROFILE = $USER;
		$page_url = "index.php?action=profile&sub=info&id";
	}
}
$dateformat_long = $CONFIG['date_format_long'];
include('inc/functions_blog.php');
?>
<script src="./jscript/prettyphoto/js/jquery-1.4.4.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="./jscript/prettyphoto/css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />
<script src="./jscript/prettyphoto/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
<div id='postpath'>
		<a title="<?php echo translate('gotofrontpage'); ?>" href="index.php"><?php echo translate('home'); ?></a>
		 &gt; <a href="index.php?action=blogs" title='<?php echo translate('showallblogs'); ?>'><?php echo translate('blog'); ?></a> 
         &gt; <a href="index.php?action=profile&id=<?php echo $USER_PROFILE->getId(); ?>"><?php echo ucf($USER_PROFILE->getFirstname()) . " " . ucf($USER_PROFILE->getLastname()); ?></a>
         &gt; <a href="index.php?action=profile&sub=info&id=<?php echo $USER_PROFILE->getId(); ?>" title='<?php echo translate('info'); ?>'><?php echo translate('info'); ?></a>
</div>

<!-- Left column START -->
<div class="leftcol">

	<!-- Profile pic START-->
	<div style="text-align: center;">	
	<?php
		if($USER_PROFILE->getAvatarpath() != "")
		{
			$profile_pic_path = $CONFIG['user_data_path'] . $USER_PROFILE->getId() . "/thumbl_" . $USER_PROFILE->getAvatarpath();
			$profile_pic_pathfull = $CONFIG['user_data_path'] . $USER_PROFILE->getId() . "/" . $USER_PROFILE->getAvatarpath();
			if(file_exists($profile_pic_path))
			{
				echo "<a href='". $profile_pic_pathfull ."' rel='prettyPhoto'><img src=\"" . $profile_pic_path . "\" alt=\"" . translate('profile_picture') . "\" class=\"profile_picture\" /></a>\n";
			}
			else
			{
				echo $profile_pic_path;
			}
		}
		else
		{
			if($USER_PROFILE->getGender() == "female")
			{
				echo "<img src=\"" . $CONFIG['user_data_path'] . "profile_female.gif\" alt=\"" . translate('profile_picture') . "\" class=\"profile_picture\" />\n";
			}
			else
			{
				echo "<img src=\"" . $CONFIG['user_data_path'] . "profile_male.gif\" alt=\"" . translate('profile_picture') . "\" class=\"profile_picture\" />\n";
			}
			if($USER->getId() == $USER_PROFILE->getId())
			{
			echo "<a href='index.php?action=profile&sub=edit_personal'>[" . translate('addprofilepicture') . "]</a>";
			}
		}
		?></div>
    <!-- Profile pic END-->
    
    <br />
    
     <div style="clear: both;">
        
    <!-- Display send pm to user START -->
    	<?php
		if(checkSession() && ($USER->getId() != $USER_PROFILE->getId()))
		{
			echo "<a href=\"index.php?action=profile&sub=pm_new&to=" . $USER_PROFILE->getID() . "\"><img src='img/pm_unread2.png' /> " . translate('send_pm') . "</a><br />\n";
		}
		?>
     <!-- Display send pm to user END -->
 
    </div>
</div>
<!-- Left column END -->

<!-- Center column START -->
<div class="midcol">

        <h3><?php echo translate('basicinformation'); ?></h3>
        <br />
        <b><?php echo translate('name'); ?>:</b> <?php echo ucf($USER_PROFILE->getFirstname()) . " " . ucf($USER_PROFILE->getLastname()); ?>
        <br /><br />
        <b><?php echo translate('country'); ?>:</b> <?php echo translate(ucf(getCountryName($USER_PROFILE->getCountry()))); ?> <img src="img/flags/16/<?php echo strtolower($USER_PROFILE->getCountry()); ?>.png" alt="<?php echo $USER_PROFILE->getCountry(); ?>" />
        <br /><br />
        <b><?php echo translate('gender'); ?>:</b> <?php echo translate($USER_PROFILE->getGender()); ?>
        <br /><br />
        <b><?php echo translate('birthday'); ?>:</b> <?php echo ucf($USER_PROFILE->getBirthday()) . " (". getAge($USER_PROFILE->getBirthday()) . strtolower(translate('years')) .")"; ?>
        <br /><br />
        <b><?php echo translate('posts'); ?>:</b> <?php echo ucf($USER_PROFILE->getPosts()); ?>
        <br /><br />
        <b><?php echo translate('lastactive'); ?>:</b> <?php echo formatDate($USER_PROFILE->getLastlogin(), $dateformat_long); ?>
        <br />
        <br />
        <h3><?php echo translate('contactinformation'); ?></h3>
        <br />
        <b><?php echo translate('email'); ?>:</b> <a href="mailto:<?php echo $USER_PROFILE->getEmail(); ?>"><?php echo $USER_PROFILE->getEmail(); ?></a>
        <br />
        <br />
        <h3><?php echo translate('general'); ?></h3>
        <br />
        <b><?php echo translate('joindate'); ?>:</b> <?php echo formatDate($USER_PROFILE->getJoined(), ''); ?>
        
        <?php 
		if($USER_PROFILE->getAbout() != "")
		{ ?>
        <br />
        <br />
        <h3><?php echo translate('about_me'); ?></h3>
        <br />
        <?php echo nl2br(wordwrap($USER_PROFILE->getAbout(), 300)); ?>
        <br />
        <?php 
		} 
		?>

</div>
<!-- Center column END -->
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
  });
</script>
<!-- Right column START -->
<div class="rightcol">
</div>
<!-- Right column END -->